package com.qf.search.controller;

import com.qf.search.service.SearchService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @author 徐老板
 * @date 2020/3/4   17:59
 */
@RestController
@RequestMapping("/search")
public class SearchController {
    private static final   Logger LOGGER = LoggerFactory.getLogger(SearchController.class);

    @Resource
    private SearchService searchService;
    //当前参数必须是json格式
    @RequestMapping("/search")
    public List<Map> searchlog(String params ){
       LOGGER.error("传过来的参数是{}",params);
        try {
            return searchService.search(params);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

    public long count(String params){
        LOGGER.error("查询长度接收到的参数是{}",params);
        try {
            return searchService.count(params);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return 0;
    }
}
